package com.hqyj.lyf.controller;

import com.hqyj.lyf.pojo.QuestionBank;

import com.hqyj.lyf.service.QuestionBankService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author Qiuluoer
 *  2022/5/28 16:20
 */
@Controller
@RequestMapping("/qubank")
public class QuestionBankController {
    @Autowired
    private QuestionBankService questionBankService;


    @RequestMapping("/quallqu")
    @ResponseBody
    public Map<String,Object> queryAllQuestion(@RequestParam(required = false,defaultValue = "1") int page,
                                               @RequestParam(required = false) int limit){
        System.out.println(limit);


        Map<String, Object> map = questionBankService.queryAllQuestion(page,limit);
        return map;
    }
    @RequestMapping("/byqu")
    @ResponseBody
    public Map<String,Object> queryByQuestion(@RequestParam(required = false,defaultValue = "1") int page,
                                              @RequestParam(required = false) int limit,QuestionBank questionBank){

        System.out.println(questionBank);
        System.out.println(page);
        System.out.println(limit);
        Map<String,Object> map = questionBankService.queryByQuestion(page,limit,questionBank);

        return map;
    }
    @PostMapping("/upqu")
    @ResponseBody
    public Map<String,Object> updateQuestion(QuestionBank questionBank){
        Map<String, Object> map = questionBankService.updateQuestion(questionBank);
        return map;

    }
    @PostMapping("/addqu")
    @ResponseBody
    public Map<String,Object> addQuestion(QuestionBank questionBank){
        Map<String, Object> map = questionBankService.addQuestion(questionBank);
        return map;

    }

//    @PostMapping("/addqus")
//    @ResponseBody
//    public Map<String,Object> addQuestions(List<QuestionBank> questions){
//        Map<String, Object> map = questionBankService.addQuestions(questions);
//        return map;
//
//    }

    @PostMapping("/delqu")
    @ResponseBody
    public Map<String,Object> deleteQuestion(@RequestBody List<Integer> quIds){
        Map<String, Object> map = questionBankService.deleteQuestion(quIds);
        return map;

    }
    @PostMapping("/delbyqu")
    @ResponseBody
    public Map<String,Object> deleteByQuId(Integer quId){
        Map<String, Object> map = questionBankService.deleteByQuId(quId);
        return map;
    }
}
